-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: foo20 check an error from grc20 package #977
Conversation
Related with #952 |
|
||
func TestErrConditions(t *testing.T) { | ||
admin := std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") | ||
empty := std.Address("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add another case?
invalid := std.Address("invalid")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grc20 package uses checkIsValidAddress
to check whether address is valid or not.
gno/examples/gno.land/p/demo/grc/grc20/util.gno
Lines 7 to 12 in 973be98
func checkIsValidAddress(addr std.Address) error { | |
if addr.String() == "" { | |
return ErrInvalidAddress | |
} | |
return nil | |
} |
unfortunately it only checks addr.String() == ""
, so that invalid
won't be invalid but valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps better to rename above function to checkIsEmptyAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ethereum ecosystem libs like Ethers and web3.js commonly utilize the isAddress
terminology, if the aim is for close parity or to minimize confusion errors for devs.
SO answer with additional context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's handle this in the other refactor #952.
In this particular case, using isAddress
doesn't seem suitable because we're dealing with an std.Address
object and checking its validity.
Creating a more general method like std.Address{}.IsValid()
would be more appropriate in the future. For now, I'll focus on improving the check in the other PR or add a comment for clarification.
Thank you all for your suggestions.
detailed infos are described in #857
TL;DR
foo20
relam doesn't check error fromgrc20
package.Checklists...
Contributors Checklist
BREAKING CHANGE: xxx
message was included in the descriptionMaintainers Checklist
CONTRIBUTING.md
BREAKING CHANGE:
in the body)